﻿app.controller('NewsCenterController', function ($scope, $http, $window, $compile, $filter, ipCookie, common, option, Upload) {
    $scope.result = {};
    $scope.dateOption = option.date;
    $scope.datetimeOption = option.datetime;

    $scope.GetNoticeDetail = function (id) {
        $scope.NewsDetail = {};
        $http({
            method: 'POST',
            url: '../NewsCenter/GetNewsDetail',
            data: { "Id": id }
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                if (ret.Code == 100) {
                    $scope.NewsDetail = ret.Data;
                    $("#newscontent").html($scope.NewsDetail.NoticeContent);
                    $("#newsnode_" + $scope.NewsDetail.NoticeType).addClass("active");
                }
                else {
                    alertify.alert(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                alertify.alert("请检查网络");
            });
    }


    $scope.GetNewsTypeDetail = function (id) {
        $scope.TypeDetail = {};
        $http({
            method: 'POST',
            url: '../NewsCenter/GetNewsTypeDetail',
            data: { "Id": id }
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                if (ret.Code == 100) {
                    $scope.TypeDetail = ret.Data;
                    $("#newsnode_" + id).addClass("active");
                }
                else {
                    alertify.alert(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                alertify.alert("请检查网络");
            });
    }

    $scope.GetNewsList = function (type, page) {
        $scope.NewsList = [];
        $http({
            method: 'POST',
            url: '../NewsCenter/GetNewsPageList',
            data: { "type": type, "page": page }
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                if (ret.Code == 100) {
                    $scope.NewsList = ret.Data.Data;
                }
                else {
                    alertify.alert(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                alertify.alert("请检查网络");
            });
    }

    $scope.GoNewsCenter = function (id, type) {
        window.open("../NewsCenter/NewsDetail?Id=" + id + "&type=" + type, "_self");
    }

});